'use strict';
module.exports = function(sequelize, DataTypes) {
  var vendor = sequelize.define('vendor', {
    id: {
      type: DataTypes.UUID,
      primaryKey: true,
      defaultValue: DataTypes.UUIDV1
    },
    name: {
      type: DataTypes.STRING,
      unique: true
    },
    locId: {
      type: DataTypes.STRING(24),
      allowNull: false,
    },
    addr: DataTypes.STRING,
    bizHoursStart: {
      type: DataTypes.STRING(8),
      validate: {
        is: /^(([0-1]?\d)|([2][0-4])):[0-6]?\d$/ig
      }
    },
    bizHoursEnd: {
      type: DataTypes.STRING(8),
      validate: {
        is: /^(([0-1]?\d)|([2][0-4])):[0-6]?\d$/ig
      }
    },
    tel: DataTypes.STRING,
    deliveryRange: DataTypes.FLOAT
  }, {
    classMethods: {
      associate: function(models) {
        // associations can be defined here
        vendor.hasMany(models.product);
        vendor.hasMany(models.carriage);
      }
    },
    paranoid: true
  });
  return vendor;
};
